<?php

/**
 * This is the model class for table "{{user_profiles}}".
 *
 * The followings are the available columns in table '{{user_profiles}}':
 * @property integer $user_id
 * @property string $nickname
 * @property string $sex
 * @property string $marital
 * @property double $timezone
 * @property string $birthday
 * @property string $phone
 * @property string $avatar
 * @property string $abbr
 * @property string $degree
 * @property string $job
 * @property string $msn
 * @property string $qq
 * @property string $note
 * @property string $facebook_url
 * @property string $twitter_url
 * @property string $googleplus_url
 */
class UserProfiles extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return UserProfiles the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{user_profiles}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('user_id, nickname, phone, avatar, abbr, job, msn, qq, facebook_url, twitter_url, googleplus_url', 'required'),
			array('user_id', 'numerical', 'integerOnly'=>true),
			array('timezone', 'numerical'),
			array('nickname', 'length', 'max'=>60),
			array('sex', 'length', 'max'=>6),
			array('marital', 'length', 'max'=>7),
			array('phone, job, msn', 'length', 'max'=>32),
			array('avatar, facebook_url, twitter_url, googleplus_url', 'length', 'max'=>255),
			array('abbr', 'length', 'max'=>2),
			array('degree', 'length', 'max'=>1),
			array('qq', 'length', 'max'=>20),
			array('birthday, note', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('user_id, nickname, sex, marital, timezone, birthday, phone, avatar, abbr, degree, job, msn, qq, note, facebook_url, twitter_url, googleplus_url', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'user_id' => 'User',
			'nickname' => 'Nickname',
			'sex' => 'Sex',
			'marital' => 'Marital',
			'timezone' => 'Timezone',
			'birthday' => 'Birthday',
			'phone' => 'Phone',
			'avatar' => 'Avatar',
			'abbr' => 'Abbr',
			'degree' => 'Degree',
			'job' => 'Job',
			'msn' => 'Msn',
			'qq' => 'Qq',
			'note' => 'Note',
			'facebook_url' => 'Facebook Url',
			'twitter_url' => 'Twitter Url',
			'googleplus_url' => 'Googleplus Url',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('user_id',$this->user_id);
		$criteria->compare('nickname',$this->nickname,true);
		$criteria->compare('sex',$this->sex,true);
		$criteria->compare('marital',$this->marital,true);
		$criteria->compare('timezone',$this->timezone);
		$criteria->compare('birthday',$this->birthday,true);
		$criteria->compare('phone',$this->phone,true);
		$criteria->compare('avatar',$this->avatar,true);
		$criteria->compare('abbr',$this->abbr,true);
		$criteria->compare('degree',$this->degree,true);
		$criteria->compare('job',$this->job,true);
		$criteria->compare('msn',$this->msn,true);
		$criteria->compare('qq',$this->qq,true);
		$criteria->compare('note',$this->note,true);
		$criteria->compare('facebook_url',$this->facebook_url,true);
		$criteria->compare('twitter_url',$this->twitter_url,true);
		$criteria->compare('googleplus_url',$this->googleplus_url,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}